import QtQuick
import QtQuick3D

import "../../framework"
//从屏幕中读取输入，控制摄像机角度
Item{
    id:root

    property InputComponent input

    property Node cameraBase
    property Node picthBase

    property point factor:Qt.point(100,100)//灵敏度


    Connections{
        target:input?input.mainMouseArea:null

        function normalizeAngle(i){
            while(i > 180)
            {
                i -= 360
            }
            while(i < -180)
            {
                i += 360
            }
            return i
        }

        function onFlick(e){
            let yaw = picthBase.eulerRotation.x
            yaw += e.y * factor.y
            yaw = normalizeAngle(yaw)

            let pitch = cameraBase.eulerRotation.y
            pitch -= e.x * factor.x
            pitch = normalizeAngle(pitch)

            picthBase.eulerRotation.x = yaw
            cameraBase.eulerRotation.y = pitch
        }
    }

    Item {
        id: __materialLibrary__
    }
}
